import QtQuick 2.0
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import "../CustomizedUIElement"
import "../ConfigManager"

Item {
    property alias lblTip: lblTip
    property var maxListHeight: 700

    Component{
        id: diConfigger
        ArrayEditor{
            sectionName: qsTr("DiConfigs")
            configModel: diConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: doConfigger
        ArrayEditor{
            sectionName: qsTr("DoConfigs")
            configModel: doConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: cylConfigger
        ArrayEditor{
            sectionName: qsTr("CylinderConfigs")
            configModel: cylConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: vacuumConfigger
        ArrayEditor{
            sectionName: qsTr("VacuumConfigs")
            configModel: vacuumConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: axisConfigger
        ArrayEditor{
            sectionName: qsTr("AxisConfigs")
            configModel: axisConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: vcmConfigger
        ArrayEditor{
            sectionName: qsTr("VCM Configs")
            configModel: vcmConfigs
            listMaxHeight: maxListHeight
            listMaxWidth: parent.parent.width
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: sAxisModuleConfigger
        ArrayEditor{
            sectionName: qsTr("Single axis module configs")
            configModel: singleAxisModuleConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: xyModuleConfigger
        ArrayEditor{
            sectionName: qsTr("XY module configs")
            configModel: xyModuleConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: xyzModuleConfigger
        ArrayEditor{
            sectionName: qsTr("XYZ module configs")
            configModel: xyzModuleConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: softLandingConfigger
        ArrayEditor{
            sectionName: qsTr("Soft landing pos configs")
            configModel: softLandingConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    Component{
        id: xyzrDebuggerConfigger
        ArrayEditor{
            sectionName: qsTr("XYZR debugger configs")
            configModel: xyzrDebuggerConfigs
            listMaxHeight: maxListHeight
            arrayItemAddRemovable: false
            Component.onCompleted: {
                init()
            }
        }
    }

    ColumnLayout{
        anchors.fill: parent
        Label{
            id: lblTip
        }
        MyTabView{
            Layout.fillHeight: true
            Layout.fillWidth: true
            id: viewer
        }
    }

    Component.onCompleted: {
        viewer.addTab("DI", diConfigger)
        viewer.addTab("DO", doConfigger)
        viewer.addTab("Vacuum", vacuumConfigger)
        viewer.addTab("Cyl", cylConfigger)
        viewer.addTab("Axis", axisConfigger)
        viewer.addTab("SingleAxis", sAxisModuleConfigger)
        viewer.addTab("XyModule", xyModuleConfigger)
        viewer.addTab("XyzModule", xyzModuleConfigger)
        viewer.addTab("VCM", vcmConfigger)
        viewer.addTab("SoftLanding", softLandingConfigger)
        viewer.addTab("XYZRDbg", xyzrDebuggerConfigger)
    }
}
